package com.hopu.haogoumall.db.mapper;

import com.hopu.haogoumall.db.module.HaogoumallComment;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.InsertProvider;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.apache.ibatis.annotations.UpdateProvider;
import org.apache.ibatis.type.JdbcType;

public interface HaogoumallCommentMapper {
    @Delete({
        "delete from haogoumall_comment",
        "where comment_id = #{commentId,jdbcType=INTEGER}"
    })
    int deleteByPrimaryKey(Integer commentId);

    @Insert({
        "insert into haogoumall_comment (comment_id, comment_value_id, ",
        "comment_type, comment_content, ",
        "comment_admin_content, user_id, ",
        "comment_has_picture, comment_pic_urls, ",
        "comment_star, comment_add_time, ",
        "comment_update_time, comment_deleted)",
        "values (#{commentId,jdbcType=INTEGER}, #{commentValueId,jdbcType=INTEGER}, ",
        "#{commentType,jdbcType=TINYINT}, #{commentContent,jdbcType=VARCHAR}, ",
        "#{commentAdminContent,jdbcType=VARCHAR}, #{userId,jdbcType=INTEGER}, ",
        "#{commentHasPicture,jdbcType=BIT}, #{commentPicUrls,jdbcType=VARCHAR}, ",
        "#{commentStar,jdbcType=SMALLINT}, #{commentAddTime,jdbcType=TIMESTAMP}, ",
        "#{commentUpdateTime,jdbcType=TIMESTAMP}, #{commentDeleted,jdbcType=BIT})"
    })
    int insert(HaogoumallComment record);

    @InsertProvider(type=HaogoumallCommentSqlProvider.class, method="insertSelective")
    int insertSelective(HaogoumallComment record);

    @Select({
        "select",
        "comment_id, comment_value_id, comment_type, comment_content, comment_admin_content, ",
        "user_id, comment_has_picture, comment_pic_urls, comment_star, comment_add_time, ",
        "comment_update_time, comment_deleted",
        "from haogoumall_comment",
        "where comment_id = #{commentId,jdbcType=INTEGER}"
    })
    @Results({
        @Result(column="comment_id", property="commentId", jdbcType=JdbcType.INTEGER, id=true),
        @Result(column="comment_value_id", property="commentValueId", jdbcType=JdbcType.INTEGER),
        @Result(column="comment_type", property="commentType", jdbcType=JdbcType.TINYINT),
        @Result(column="comment_content", property="commentContent", jdbcType=JdbcType.VARCHAR),
        @Result(column="comment_admin_content", property="commentAdminContent", jdbcType=JdbcType.VARCHAR),
        @Result(column="user_id", property="userId", jdbcType=JdbcType.INTEGER),
        @Result(column="comment_has_picture", property="commentHasPicture", jdbcType=JdbcType.BIT),
        @Result(column="comment_pic_urls", property="commentPicUrls", jdbcType=JdbcType.VARCHAR),
        @Result(column="comment_star", property="commentStar", jdbcType=JdbcType.SMALLINT),
        @Result(column="comment_add_time", property="commentAddTime", jdbcType=JdbcType.TIMESTAMP),
        @Result(column="comment_update_time", property="commentUpdateTime", jdbcType=JdbcType.TIMESTAMP),
        @Result(column="comment_deleted", property="commentDeleted", jdbcType=JdbcType.BIT)
    })
    HaogoumallComment selectByPrimaryKey(Integer commentId);

    @UpdateProvider(type=HaogoumallCommentSqlProvider.class, method="updateByPrimaryKeySelective")
    int updateByPrimaryKeySelective(HaogoumallComment record);

    @Update({
        "update haogoumall_comment",
        "set comment_value_id = #{commentValueId,jdbcType=INTEGER},",
          "comment_type = #{commentType,jdbcType=TINYINT},",
          "comment_content = #{commentContent,jdbcType=VARCHAR},",
          "comment_admin_content = #{commentAdminContent,jdbcType=VARCHAR},",
          "user_id = #{userId,jdbcType=INTEGER},",
          "comment_has_picture = #{commentHasPicture,jdbcType=BIT},",
          "comment_pic_urls = #{commentPicUrls,jdbcType=VARCHAR},",
          "comment_star = #{commentStar,jdbcType=SMALLINT},",
          "comment_add_time = #{commentAddTime,jdbcType=TIMESTAMP},",
          "comment_update_time = #{commentUpdateTime,jdbcType=TIMESTAMP},",
          "comment_deleted = #{commentDeleted,jdbcType=BIT}",
        "where comment_id = #{commentId,jdbcType=INTEGER}"
    })
    int updateByPrimaryKey(HaogoumallComment record);
}